<?php

/**
 * 幻灯片右侧说明 小挂件
 */
class FlashWidget extends CoreWidget{
    public $staticsPath;
    public $code = 'index_flash_section';
    public $type;
    public $num;
    public $is_show;
    public $role;
    private $path;
    public function init(){
        if($this->getRole(Yii::app()->user->getState('user_role'),Yii::app()->user->getState('role_salt'),'manage_index_flash')){
            $this->role = true;
        }else{
            $this->role = false;
        }
        //获取section表信息
        $section_info = Section::model()->getFindSection($this->code);
        $this->type = $section_info->type;
        $this->num = $section_info->num;
        $this->is_show = $section_info->is_show;
        $assets = Yii::getPathOfAlias('application').DIRECTORY_SEPARATOR.'widgets'.DIRECTORY_SEPARATOR.'flash_block'.DIRECTORY_SEPARATOR.'statics'.DIRECTORY_SEPARATOR;
        //静态文件夹
        $this->path = Yii::app()->getAssetManager()->publish($assets, false, -1, YII_DEBUG);//强制生成
    }
    public function run(){
        if($this->is_show==1){
            if($this->type==1){
                $this->render('flash_block',array('role'=>$this->role,'staticsPath'=>$this->staticsPath));
            }
        }
    }


}